"""
    Author:
    Date: 2019-01-22

    微信公众平台: GM管理后台
"""

from entities import archive_mgr
from entities.err import *

from . import helpers
from utils.log import Log


def api_archive_server_data(request):
    """ 用户消费上报接口 """
    Log.info("Archive server data ......")
    # 检测签名
    fields = []
    params = helpers.ApiParamsChecker(request.POST, fields)
    if not params.is_valid_signature():
        return ERROR_INVALID_SIGN, None

    # 保存消费数据
    success = archive_mgr.archive_server_data()
    if not success:
        Log.error("Archive server data ...... failed!")
        return ERROR_SYSTEM_ERROR, None

    Log.info("Archive server data ...... OK.")
    return ERROR_NO_ERROR, {}


if __name__ == '__main__':
    print('ok')
